package com.taotao.observer1;


import com.taotao.observer1.impl.IntegralObServer;
import com.taotao.observer1.impl.MsgSubject;
import com.taotao.observer1.impl.TextMessageObserver;
import com.taotao.observer1.impl.WeChatObserver;

/**
 * @Author: wangjin
 * @CreateTime: 2022-07-03  10:54
 */
public class Test1 {
    public static void main(String[] args) {
        //将观察者 存入到对象集合
        Observer  observer1=new TextMessageObserver();
        Observer  observer2=new WeChatObserver();
        Observer  observer3=new IntegralObServer();
        MsgSubject msgSubject=new MsgSubject();
        msgSubject.addObserver(observer1);
        msgSubject.addObserver(observer2);
        msgSubject.addObserver(observer3);
        //通知给所有的观察者
        msgSubject.notifyAll("taotao");

        IntegralSubject integralSubject=new IntegralSubject();
        Observer  observer4=new IntegralObServer();
        integralSubject.addObserver(observer4);
        integralSubject.notifyAll("['openId':'1','4444444']");
    }
}
